<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="./js/jquery.js"></script>
  </head>
  <body>
    <button>后端请求数据</button>
    <div class="box"></div>
    <script>
      $(function () {
        $("button").click(function () {
          $.ajax({
            url: "http://localhost:8080/data",
            type: "get",
            dataType: "json",
            success: function (data) {
              console.log(data.obj);
              let str = "";
              data.obj.forEach((itme) => {
                str += `        <p>姓名:${itme.name}</p>
                                 <p>年龄:${itme.age}</p>
                                <p>性别: ${itme.sex}</p>
                                <p> 地址:${itme.address}</p>
                      `;
              });
              $(".box").html(str);
            },
          });
        });
      });
    </script>
  </body>
</html>
